﻿using UnityEngine;
using UnityEngine.Events;


namespace UIFrame
{
    public class CommonItem : MonoBehaviour
    {    
        //事件
        protected UnityAction myAction;

        /// <summary>
        /// 注册事件
        /// </summary>
        /// <param name="action"></param>
        public virtual void RegisterEvent(UnityAction action)
        {
            myAction += action;
        }

        /// <summary>
        /// 移除事件
        /// </summary>
        /// <param name="action"></param>    
        public virtual void RemoveEvent(UnityAction action)
        {
            myAction -= action;
        }
    
        /// <summary>
        /// 激活事件
        /// </summary>
        public virtual void ActivationEvent()
        {
            myAction?.Invoke();
        }
    }
}
